//candy
#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans,L,R;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	if(r-l+1>=n)
	{
		printf("%d",n-1);
		return 0;
	}
	L=l/n*n;
	R=(r+n)/n*n+1;
	for(int i=L;i<=R;i+=n)
	{
		for(int j=i-1;j>=i-n;j--)
		{
			if(ans==n-1)
			{
				printf("%d",ans);
				return 0;
			}
			if(j<=r&&j>=l)
			ans=max(ans,j%n);
		}
	}
	printf("%d",ans);
	return 0;
}
